import { Component, OnInit } from '@angular/core';
import { ApiService } from '../../../../providers/ApiPro.service';
import { parts } from '../HuoMesstmp.model';

@Component({
  selector: 'app-MessCusInfo',
  templateUrl: './MessCusInfo.component.html',
  styleUrls: ['./MessCusInfo.component.scss']
})
export class MessCusInfoComponent implements OnInit {
  data = [];
  public _total = 0;
  public pageIndex = 1;
  public parts: parts = new parts();


  constructor(
      public apiService: ApiService,
  ) { }

  ngOnInit() {
    this.loadAll();
  }

    loadAll(){
    let url = "findBigCustomers";
    if(!this.parts.companyName){
      delete this.parts.companyName;    
    }
    if(!this.parts.customerAccount){
      delete this.parts.customerAccount;    
    }
    if(!this.parts.customerMobile){
      delete this.parts.customerMobile;    
    }
    console.log(this.parts);
    this.apiService.get(url,this.parts)
      .then(res =>{
        console.log(res);
        this._total = res.totalCount;
        this.data = res.result;
      })
  }

  resetIndex(e) {
        this.parts.setPage(e);
        this.loadAll();
  }


}
